package com.rongzhe.house.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ListView;
import android.widget.TextView;

import com.rongzhe.house.R;
import com.rongzhe.house.entity.voo.City;
import com.rongzhe.house.presenter.ChooseCityPresenter;
import com.rongzhe.house.ui.adapter.CityAdapter;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnItemClick;

/**
 * Created by huang on 2017/11/26.
 */

public class ChooseCityActivity extends BaseActivity<ChooseCityPresenter> {
    @BindView(R.id.text_current_city)
    TextView textCurrentCity;
    @BindView(R.id.list_city)
    ListView listCity;
    private CityAdapter mCityAdapter;

    @Override
    protected ChooseCityPresenter createPresenter() {
        return new ChooseCityPresenter(this);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choosee_city);
        ButterKnife.bind(this);
        mCityAdapter = new CityAdapter(this);
        listCity.setAdapter(mCityAdapter);
    }

    @OnItemClick(R.id.list_city)
    public void onListCityClick(int position) {
        mPresenter.onClityItemClick((City) mCityAdapter.getItem(position));
    }

    public void setListCity(List<City> data) {
        mCityAdapter.setData(data);
    }

    @Override
    protected String getActionTitle() {
        return getString(R.string.choose_city);
    }
}
